﻿using System;
using System.Data;
using System.Data.SqlClient;
using Moq;
using JTLeigh.Commerce.Spencer.Core.Common;

namespace JTLeigh.Commerce.Spencer.Core.Testing.Mocks.Data
{

	/// <summary>
	/// Mock database command that throws an <see cref="Exception"/> when <see cref="IDbCommand.ExecuteScalar"/> 
	/// is called.
	/// </summary>
	[CLSCompliant(false)]
	public class MockDatabaseCommandExecuteScalarThrows : BaseMockDatabaseCommand
	{

		#region Constructors

		/// <summary>
		/// Initializes a new instance of the <see cref="MockDatabaseCommandExecuteScalarThrows"/>
		/// class with the specified schema name, command name, parameter count, and exception.
		/// </summary>
		/// <param name="schemaName">The schema name.</param>
		/// <param name="commandName">The command name.</param>
		/// <param name="parameterCount">The number of parameters that should be passed to the
		/// command.</param>
		/// <param name="exception">The <see cref="Exception"/> to throw when <see cref="IDbCommand.ExecuteScalar"/> 
		/// is called.</param>
		public MockDatabaseCommandExecuteScalarThrows(string schemaName, string commandName, int parameterCount, Exception exception)
			: base(schemaName, commandName, parameterCount)
		{
			Safety.AssertArgumentNotNull("exception", exception);

			Expect(x => x.ExecuteScalar()).Throws(exception).AtMostOnce();
		}

		#endregion // Constructors

	}

}
